package com.andkrup.easygame.game {
	import com.andkrup.easygame.game.commands.IGameCommand;	
	
	import mx.core.ClassFactory;
	import mx.core.IFactory;
	
	/**
	 * @author Andkrup
	 */
	public class CommandFactory extends ClassFactory implements IFactory {
		public function CommandFactory(generator : Class = null, args:Array = null) {
			super(generator);
			properties = args;
		}
		
		public override function newInstance():*{
			var rt:Object;
			try{
				rt = new generator(properties as Array);
			}
			catch(err:Error){
				trace("error creating instance, stacktrace:\n"+err.getStackTrace());
			}
			return rt as IGameCommand;
		}
	}
}
